{% extends "BackendBundle::backend.html.twig" %}

{% block title %}{{ "Administracion Servicios"|trans }}{% endblock %}

{% set vars = {'ruta' : app.request.attributes.get('_route')} %}

{% block header %}

    {% include "BackendBundle::topmenu.html.twig" with vars %}

{% endblock %}

{% block left %}

    {% include "ServiciosBundle:Default:menuleft.html.twig" with vars %}

{% endblock %}

{% block content %}

    <div class="span9">
        
        <h2>{{"Servicios"|trans}}</h2>
        
        <fieldset>
            <legend>{{"Listado de Servicios"|trans}}</legend>
            
            {% if app.session.hasFlash('success') %}
                <div class="flash-notice alert alert-success">
                    <h4 class="alert-heading">{{ "Ok"|trans }}!</h4>                     
                    {{ app.session.flash('success') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('error') %}
                <div class="flash-notice alert alert-error">
                    <h4 class="alert-heading">{{ "Error"|trans }}!</h4>                        
                    {{ app.session.flash('error') }}
                </div>
            {% endif %}

            {% if app.session.hasFlash('info') %}
                <div class="flash-notice alert alert-info">
                    <h4 class="alert-heading">{{ "Info"|trans }}!</h4>
                    <p>{{ app.session.flash('info') }}</p>
                </div>
            {% endif %}
            
            {% if languages|length != 0 and servicios|length !=0 %}
            
            <div class="btn-toolbar">
                <div class="btn-group">
                    
                    {% for language in languages %}

                        <a href="{{ path("ServiciosBundle_homepage_idioma", {'ididioma': language.id}) }}" class="btn{% if ididioma == language.id %} btn-primary{% endif %}">{{ language.idioma }}</a>

                    {% endfor %}
                    
                </div>
            </div>
            
            {% endif %}
            
            <div class="well">
                
                {% if servicios|length != 0 %}
                
                    <table class="table">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>{{ "Nombre Servicio"|trans }}</th>
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>

                            {% for servicio in servicios %}

                            <tr>
                                <td style="width: 50px; vertical-align:middle">{{servicio.idservicio}}</td>
                                <td style="vertical-align:middle">{{servicio.nombreservicio}}</td>
                                <td style="text-align:right;">
                                    
                                    {% if servicio.traduccio == 0 %}
                                    
                                        <a href="{{ path("ServiciosBundle_tradu", {'ididioma': ididioma, 'idservicio': servicio.idservicio}) }}" class="btn btn-small btn-warning" title="{{ "Crear Traducción"|trans }}"><i class="icon-globe icon-white">&nbsp;</i></a>
                                    
                                    {% else %}
                                    
                                        <a href="{{ path("ServiciosBundle_editar", {'ididioma': ididioma, 'idservicio': servicio.idservicio}) }}" class="btn btn-small" title="{{ "Editar"|trans }}"><i class="icon-pencil">&nbsp;</i></a>
                                        <a href="{{ path("ServiciosBundle_borrar", {'ididioma': ididioma, 'idservicio': servicio.idservicio}) }}" class="btn btn-danger" title="{{ "Borrar"|trans }}"><i class="icon-trash icon-white">&nbsp;</i></a>
                                    
                                    {% endif %}
                                    
                                </td>
                            </tr>

                            {% endfor %}        

                        </tbody>
                    </table>
                
                {% else %}
                
                    <p>{{ "No hay servicios creados"|trans }}</p>
                
                {% endif %}

            </div>
            
        </fieldset>
        
    </div>

{% endblock %}
